<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务调度列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>仓库类型：</label>
                            <select id="dpRepoType" name="dpRepoType" th:with="type=${@dict.getType('repo_type')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>调度名称：</label>
                            <input type="text" name="dpName"/>
                        </li>
                        <li>
                            <label>调度地址：</label>
                            <input type="text" name="dpPath"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('busi:dispatcher:edit')}]];
    var removeFlag = [[${@permission.hasPermi('busi:dispatcher:remove')}]];
    var datas = [[${@dict.getType('repo_type')}]];
    var warn_level = [[${@dict.getType('warn_level')}]];
    var prefix = ctx + "busi/dispatcher";
    var ktExeStatus = [[${@dict.getType('kt_exe_status')}]];

    function addRepo() {
        $.operate.add($("#dpRepoType").val())
    }


    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "任务调度",
            sortName: "createdTime",
            sortOrder: "DESC",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'dpName',
                    title: '调度名称'
                },
                {
                    field: 'dpTypeName',
                    title: '调度类型'
                },
                {
                    field: 'dpPath',
                    title: '调度地址'
                },
                {
                    field: 'dpRepoType',
                    title: '资源库类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, row.dpRepoType);
                    }
                },
                {
                    field: 'repoName',
                    title: '资源库名称'
                },
                {
                    field: 'paramsGroupName',
                    title: '参数组'
                },
                {
                    field: 'warnMsgIds',
                    title: '预警'
                },
                {
                    field: 'warnLevel',
                    title: '预警等级',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(warn_level, row.warnLevel);
                    }
                },
                {
                    field: 'currentStatus',
                    title: '当前任务状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(ktExeStatus, row.currentStatus);
                    }
                },
                {
                    field: 'createdTime',
                    title: '创建时间'
                }]
        };
        $.table.init(options);

        $("#dpRepoType").bind("change", function () {
            $.table.refreshOptions(options);
        });
    });

    function submitHandler() {
        var rows = $.table.selectColumns("id");
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.close();
        return rows.join();
    }
</script>
</body>
</html>